package cn.dubito.springcloud.service;

import cn.dubito.springcloud.entity.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 服务降级处理
 *
 * @author liliang
 * @description:
 * @date 2018/5/21.
 */
@Component
public class DeptClientServiceFallBackFactory implements FallbackFactory<DeptClientService> {

    @Override
    public DeptClientService create(Throwable throwable) {
        return  new DeptClientService() {
            @Override
            public boolean add(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long deptNo) {
                return new Dept().setDeptNo(deptNo)
                        .setDeptName("改 ID" + deptNo + "没有对应的信息")
                        .setDbSource("no this databases in Mysql");
            }

            @Override
            public List<Dept> list() {
                return null;
            }
        };
    }
}
